package main

import (
	"fmt"
)

type Book struct {
	bookname string
	price float64
}

type person struct {
	name string
	age int
	book []Book
}

func main()  {
	p1:=person{}
	p1.name="王二狗"
	p1.age=30
	b1:=Book{"火影",14.4}
	b2:=Book{"金瓶梅",26.4}
	books:=[]Book{b1,b2,Book{"小猪",33.5}}
	for i,v :=range books{
		fmt.Println(i,v.bookname,v.price)
	}

	p2:=person{
		"老王",
		43,
		make([]Book,0,10),
	}
	p2.book=append(p2.book,Book{"西游记",23.4})
	p2.book=append(p2.book,Book{"西游记1",23.4})
	p2.book=append(p2.book,Book{"西游记1",23.4})
	p2.book=append(p2.book,Book{"西游记2",23.4})
	fmt.Println(p2)

}
